<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
</head>
<body class="layui-layout-body">


<blockquote class="layui-elem-quote"  >
                <div class=" layui-form" >
                    <div class="layui-form-item"  >


                        <div class="layui-input-inline" style="width: 100px">
                            <select name="" lay-verify="required" id="khSearchKind" lay-filter="khSearchKind" >

                                <option value="khjc">客户简称</option>
                                <option value="khzjm">助记码</option>
                            </select>

                            <select   lay-filter="dingdan" id="ddSearchKind" lay-filter="ddSearchKind" >
                                <option value="ddzt">订单状态</option>
                                <option value="ddh">订单号</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <select    class="layui-input" id="khSearchContent" lay-search><option value="">请选择</option></select>

                            <div id="ddh" style="display: none" ><select   class="layui-input"  id="ddhSearchContent" lay-search><option value="">请选择</option></select></div>
                            <div id="ddzt"  >
                                <select name=""   id="ddSearchContent">
                                    <option value="">请选择订单状态</option>
                                    <option value="待发布">待发布</option>
                                    <option value="已发布">已发布</option>
                                    <option value="已完成">已完成</option>
                                </select>
                            </div>
                        </div>



                        <div class="layui-input-inline" style="width: 100px">
                            <select name="city"  id="xlSearchKind" lay-filter="xlSearchKind" >
                                <option value="xlmc">线路名称</option>
                                <option value="xlzjm">助记码</option>
                            </select>
                            <select name="city" lay-verify="required" id="qySearchKind" lay-filter="qySearchKind">
                                <option value="qymc">区域名称</option>
                                <option value="qyzjm">助记码</option>
                            </select>
                        </div>

                        <div class="layui-input-inline">
                            <select type="text"  class="layui-input" id="xlSearchContent" lay-search><option value="">请选择</option></select>
                            <select type="text"  class="layui-input" id="qySearchContent" lay-search><option value="">请选择</option></select>
                        </div>

                        <div class="layui-input-inline" style="width: 100px">
                            <label class="layui-form-label">订单起始日期</label>
                            <label class="layui-form-label">订单结束日期</label>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  class="layui-input"   id="searchQsrqContent">
                            <input type="text"  class="layui-input" id="searchJsrqContent">
                        </div>
                        <div class="layui-input-inline" style="width: 100px">
                            <label class="layui-form-label">星期</label>
                        </div>
                        <div class="layui-input-inline" style="width: 100px">
                            <select class="layui-form-label" id="xingqi">
                                <option value=""></option>
                                <option value="Monday">星期一</option>
                                <option value="Tuesday">星期二</option>
                                <option value="Wednesday">星期三</option>
                                <option value="Tuesday">星期四</option>
                                <option value="Friday">星期五</option>
                                <option value="Saturday">星期六</option>
                                <option value="Sunday">星期日</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="width: 80px">
                            <button class="layui-btn layui-btn-normal" id="search">点击搜索</button>
                            <button type="button" class="layui-btn layui-btn-normal" id="all">显示全部</button>
                        </div>


                        <div class="layui-input-inline" style="width: 100px">
                            <label class="layui-form-label">订单日期</label>

                        </div>
                        <div class="layui-input-inline" style="width: 90px">
                            <input type="text"  class="layui-input" id="ddrq">
                        </div>



                        <div class="layui-input-inline " style=" width:10%; position: absolute;right:  10px ">
                            <button type="button" class="layui-btn layui-btn-normal" id="newOrder">&nbsp&nbsp&nbsp生成订单&nbsp&nbsp&nbsp&nbsp</button>
                            <button type="button" class="layui-btn layui-btn-normal" id="newOtherOrder">新增零散订单</button>

                        </div>

                </div>
                </div>
</blockquote>
        <div class="layui-row">
            <div class="layui-col-xs12">
                <script type="text/html" id="opera">

                    {{#  if(d.ddzt != '待发布'){ }}
                    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</button>
                    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="addcar">加车</button>
                    <button class="layui-btn  layui-btn-xs layui-btn-disabled" disabled="disabled" lay-event="delete">删除</button>
                    <button class="layui-btn  layui-btn-xs layui-btn-disabled" disabled="disabled" lay-event="post">发布</button>

                    {{# }else { }}
                    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</button>
                    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="addcar">加车</button>
                    <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</button>
                    <button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="post">发布</button>
                    {{#  } }}


                </script>

                <table id="table" lay-filter="Table"></table>

            </div>
        </div>




<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>

<script src="../js/tools.js"></script>

<script>
    //JavaScript代码区域
    layui.use(['form' ,'table','jquery','layer','element','laydate'], function(){
        var form = layui.form;
        var table = layui.table;
        var $ = layui.$;
        var element = layui.element;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var tableheight=  'full-130';
        var tablewidth = 75;
        var currentPage = 1;




       //搜索的订单状态还是订单号
        form.on('select(dingdan)',function (data) {
            if(data.value == "ddh"){
                $("#ddzt").css("display","none");
               $("#ddh").css("display","block");
                $("#ddhSearchContent").empty();
                $.ajax({
                    url: contextPath+"/order",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#ddhSearchContent").empty();
                        $("#ddhSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].ddh+ "'>"+res.list[i].ddh+"</option>";
                            $("#ddhSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else if(data.value == "ddzt"){
                $("#ddh").css("display","none");
                $("#ddzt").css("display","block");

            }
        });


        //执行一个laydate实例
        laydate.render({
            elem: '#ddrq' //指定元素
            ,theme:'#0099FF'
            ,format:'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#searchQsrqContent' //指定元素
            ,theme:'#0099FF'
            ,format:'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#searchJsrqContent' //指定元素
            ,theme:'#0099FF'
            ,format:'yyyy-MM-dd'
        });

        //零散订单
        $("#newOtherOrder").on("click",function () {
            layer.open({
                cancel: function(index, layero){
                    var faIndex = index;
                    layer.confirm('确定要关闭么?未保存的信息将会丢失!', {icon: 3, title:'提示'}, function(index){
                        //do something
                        layer.close(index);
                        layer.close(faIndex);
                    });
                    return false
                },
                type: 2,
                title: '新建零散订单',
                maxmin: true,
                 //点击遮罩关闭层
                area : ['80%' , '40%'],
                content: ['./newOtherOrder.html','no'],

                end:function(){
                    $.ajax({
                        url: contextPath+"/order",
                        type: "GET",
                        contentType:"application/json;charset=utf-8",
                        dataType:"json",
                        success: function(res) {
                            table.render({
                                elem: '#table'
                                ,height:tableheight
                                ,data:res.list
                                ,page: {
                                    curr: currentPage //重新从第 1 页开始
                                } //开启分页
                                ,limit:10
                                ,id:'table'
                                ,cellMinWidth: tablewidth
                                ,cols: [[ //表头
                                    {type:'numbers', title: '序号',  align:'center'}
                                    ,{field: 'ddh', title: '订单号' ,align:'center'}
                                    ,{field: 'ddzt', title: '订单状态',align:'center'}
                                    ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                    ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                    ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                    ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                    ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                    ,{field: 'huowu', title: '货物' ,align:'center'}
                                    ,{field: 'yunfei', title: '运费' ,align:'center'}
                                    ,{ title:'操作', align:'center', templet: '#opera',width:200}
                                ]]

                                ,done: function(res, curr, count){
                                    //得到当前页码
                                    console.log(curr);
                                    currentPage = curr;
                                }
                            });
                        }

                    });
                }
            });

        });
        //生成订单
        $("#newOrder").on("click",function () {
            console.log($("#ddrq").val());
            if($("#ddrq").val() == ""){
                layer.msg("请选择生成订单日期！");

            }else{
                $.ajax({
                    url: contextPath+"/order/"+$("#ddrq").val(),
                    type: "POST",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        layer.msg(res.message);
                        $.ajax({
                            url: contextPath+"/order",
                            type: "GET",
                            contentType:"application/json;charset=utf-8",
                            dataType:"json",
                            success: function(res) {
                                table.render({
                                    elem: '#table'
                                    ,height:tableheight
                                    ,data:res.list
                                    ,page: {
                                        curr: currentPage //重新从第 1 页开始
                                    } //开启分页
                                    ,limit:10
                                    ,id:'table'
                                    ,cellMinWidth: tablewidth
                                    ,cols: [[ //表头
                                        {type:'numbers', title: '序号',  align:'center'}
                                        ,{field: 'ddh', title: '订单号' ,align:'center'}
                                        ,{field: 'ddzt', title: '订单状态',align:'center'}
                                        ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                        ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                        ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                        ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                        ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                        ,{field: 'huowu', title: '货物' ,align:'center'}
                                        ,{field: 'yunfei', title: '运费' ,align:'center'}
                                        ,{ title:'操作', align:'center', templet: '#opera',width:200}
                                    ]]

                                    ,done: function(res, curr, count){
                                        //得到当前页码
                                        console.log(curr);
                                        currentPage = curr;
                                    }
                                });
                            }

                        });
                    }

                });
            }
        });
//
        //  渲染搜索 select
        form.on("select(khSearchKind)",function (data) {
            if(data.value == "khjc" ){
                $("#khSearchContent").empty();
                $.ajax({
                    url: contextPath+"/cstmr",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#khSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].khjc+ "'>"+res.list[i].khjc+"</option>";
                            $("#khSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else if(data.value == "khzjm" ){
                $("#khSearchContent").empty();
                $.ajax({
                    url: contextPath+"/cstmr",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#khSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].xlzjm+"'>"+res.list[i].xlzjm+"</option>";
                            $("#khSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else{
                $("#khSearchContent").empty();
            }

        });

        form.on("select(xlSearchKind)",function (data) {
            if(data.value == "xlmc" ){
                $("#xlSearchContent").empty();
                $.ajax({
                    url: contextPath+"/road",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#xlSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].xlmc+ "'>"+res.list[i].xlmc+"</option>";
                            $("#xlSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else if(data.value == "xlzjm" ){
                $("#xlSearchContent").empty();
                $.ajax({
                    url: contextPath+"/road",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#xlSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].xlzjm+"'>"+res.list[i].xlzjm+"</option>";
                            $("#xlSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else{
                $("#xlSearchContent").empty();
            }

        });

        form.on("select(khSearchKind)",function (data) {
            if(data.value == "khjc" ){
                $("#khSearchContent").empty();
                $.ajax({
                    url: contextPath+"/cstmr",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#khSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].khjc+ "'>"+res.list[i].khjc+"</option>";
                            $("#khSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else if(data.value == "khzjm" ){
                $("#khSearchContent").empty();
                $.ajax({
                    url: contextPath+"/cstmr",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#khSearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].khzjm+"'>"+res.list[i].khzjm+"</option>";
                            $("#khSearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else{
                $("#khSearchContent").empty();
            }

        });

        form.on("select(qySearchKind)",function (data) {
            if(data.value == "qymc" ){
                $("#qySearchContent").empty();
                $.ajax({
                    url: contextPath+"/area",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#qySearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].qymc+ "'>"+res.list[i].qymc+"</option>";
                            $("#qySearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else if(data.value == "qyzjm" ){
                $("#qySearchContent").empty();
                $.ajax({
                    url: contextPath+"/area",
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        $("#qySearchContent").append("<option value=''>请选择</option>");
                        for(var i in res.list){
                            var option = "<option value='"+ res.list[i].zjm+"'>"+res.list[i].zjm+"</option>";
                            $("#qySearchContent").append(option);
                        };
                        form.render('select');
                    }
                });
            }else{
                $("#qySearchContent").empty();
            }

        });

        //table实例
        $("#all").on('click',function () {
            $.ajax({
                url: contextPath+"/order",
                type: "GET",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                success: function(res) {
                    table.render({
                        elem: '#table'
                        ,height:tableheight
                        ,data:res.list
                        ,page: {
                            curr: currentPage //重新从第 1 页开始
                        } //开启分页
                        ,limit:10
                        ,id:'table'
                        ,cellMinWidth: tablewidth
                        ,cols: [[ //表头
                            {type:'numbers', title: '序号',  align:'center'}
                            ,{field: 'ddh', title: '订单号' ,align:'center'}
                            ,{field: 'ddzt', title: '订单状态',align:'center'}
                            ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                            ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                            ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                            ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                            ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                            ,{field: 'huowu', title: '货物' ,align:'center'}
                            ,{field: 'yunfei', title: '运费' ,align:'center'}
                            ,{ templete:'#', title:'操作', align:'center', toolbar: '#opera',width:200}
                        ]]

                        ,done: function(res, curr, count){
                            //得到当前页码
                            console.log(curr);
                            currentPage = curr;
                            //清空搜索url
                            url="";
                        }
                    });
                }

            });

        });

        $.ajax({
            url: contextPath+"/order",
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {
                table.render({
                    elem: '#table'
                    ,height:tableheight
                    ,data:res.list
                    ,page: {
                        curr: currentPage //重新从第 1 页开始
                    } //开启分页
                    ,limit:10
                    ,id:'table'
                    ,cellMinWidth: tablewidth
                    ,cols: [[ //表头
                        {type:'numbers', title: '序号',  align:'center'}
                        ,{field: 'ddh', title: '订单号' ,align:'center'}
                        ,{field: 'ddzt', title: '订单状态',align:'center'}
                        ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                        ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                        ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                        ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                        ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                        ,{field: 'huowu', title: '货物' ,align:'center'}
                        ,{field: 'yunfei', title: '运费' ,align:'center'}
                        ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                    ]]

                    ,done: function(res, curr, count){
                        //得到当前页码
                        console.log(curr);
                        currentPage = curr;
                    }
                });
            }

        });

//监听表格
        table.on('tool(Table)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                ,layEvent = obj.event; //获得 lay-event 对应的值
            if(layEvent === 'detail'){
                layer.open({
                    cancel: function(index, layero){
                        var body = layer.getChildFrame('body',index);
                        var faIndex = index;
                        console.log(layero);
                        if(!(body.contents().find("#modiSub").hasClass("layui-btn-disabled"))){

                            layer.confirm('确定要关闭么?未保存的信息将会丢失!', {icon: 3, title:'提示'}, function(index){
                                //do something
                                layer.close(index);
                                layer.close(faIndex);
                            });
                        }else {
                            layer.close(faIndex);
                        }

                        return false
                    },
                    type: 2,
                    title: '查看订单信息',
                    maxmin: true,
                     //点击遮罩关闭层
                    area :  ['80%' , '40%'],
                    content: ['./lookOrder.html','no'],
                    success:function(layero,index){
                        console.log(data);
                        var body = layer.getChildFrame('body',index);

                        for(var i in data){
                            body.contents().find("[name='"+i+"']").val(eval("data."+i));
                        }
                    },
                    end:function(){
                        var endurl ="";
                        endurl = url?url:contextPath+"/order";
                        $.ajax({
                            url:endurl,
                            type: "GET",
                            contentType:"application/json;charset=utf-8",
                            dataType:"json",
                            success: function(res) {
                                table.render({
                                    elem: '#table'
                                    ,height:tableheight
                                    ,data:res.list
                                    ,page: {
                                        curr: currentPage //重新从第 1 页开始
                                    } //开启分页
                                    ,limit:10
                                    ,id:'table'
                                    ,cellMinWidth: tablewidth
                                    ,cols: [[ //表头
                                        {type:'numbers', title: '序号',  align:'center'}
                                        ,{field: 'ddh', title: '订单号' ,align:'center'}
                                        ,{field: 'ddzt', title: '订单状态',align:'center'}
                                        ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                        ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                        ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                        ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                        ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                        ,{field: 'huowu', title: '货物' ,align:'center'}
                                        ,{field: 'yunfei', title: '运费' ,align:'center'}
                                        ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                                    ]]

                                    ,done: function(res, curr, count){
                                        //得到当前页码
                                        console.log(curr);
                                        currentPage = curr;
                                    }
                                });
                            }

                        });
                    }
                });
            } else if(layEvent === 'delete'){
                layer.confirm('确定删除？', function(index){
                    obj.del(); //删除对应行（tr）的DOM结构
                    layer.close(index);
                    //向服务端发送删除指令
                    $.ajax({
                        url: contextPath+"/order/"+data.ddid,
                        type: "DELETE",
                        contentType:"application/json;charset=utf-8",
                        dataType:"json",
                        success: function(res) {
                            layer.msg(res.message);
                            $.ajax({
                                url: contextPath+"/order",
                                type: "GET",
                                contentType:"application/json;charset=utf-8",
                                dataType:"json",
                                success: function(res) {
                                    table.render({
                                        elem: '#table'
                                        ,height:tableheight
                                        ,data:res.list
                                        ,page: {
                                            curr: currentPage //重新从第 1 页开始
                                        } //开启分页
                                        ,limit:10
                                        ,id:'table'
                                        ,cellMinWidth: tablewidth
                                        ,cols: [[ //表头
                                            {type:'numbers', title: '序号',  align:'center'}
                                            ,{field: 'ddh', title: '订单号' ,align:'center'}
                                            ,{field: 'ddzt', title: '订单状态',align:'center'}
                                            ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                            ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                            ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                            ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                            ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                            ,{field: 'huowu', title: '货物' ,align:'center'}
                                            ,{field: 'yunfei', title: '运费' ,align:'center'}
                                            ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                                        ]]

                                        ,done: function(res, curr, count){
                                            //得到当前页码
                                            console.log(curr);
                                            currentPage = curr;
                                        }
                                    });
                                }

                            });
                        }
                    });
                });
            }else if(layEvent === 'post'){

                $.ajax({
                    url: contextPath+"/order/"+data.ddid,
                    type: "PUT",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        layer.msg(res.message);
                        $.ajax({
                            url: contextPath+"/order",
                            type: "GET",
                            contentType:"application/json;charset=utf-8",
                            dataType:"json",
                            success: function(res) {
                                table.render({
                                    elem: '#table'
                                    ,height:tableheight
                                    ,data:res.list
                                    ,page: {
                                        curr: currentPage //重新从第 1 页开始
                                    } //开启分页
                                    ,limit:10
                                    ,id:'table'
                                    ,cellMinWidth: tablewidth
                                    ,cols: [[ //表头
                                        {type:'numbers', title: '序号',  align:'center'}
                                        ,{field: 'ddh', title: '订单号' ,align:'center'}
                                        ,{field: 'ddzt', title: '订单状态',align:'center'}
                                        ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                        ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                        ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                        ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                        ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                        ,{field: 'huowu', title: '货物' ,align:'center'}
                                        ,{field: 'yunfei', title: '运费' ,align:'center'}
                                        ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                                    ]]

                                    ,done: function(res, curr, count){
                                        //得到当前页码
                                        console.log(curr);
                                        currentPage = curr;
                                    }
                                });
                            }

                        });
                    }
                });

            }else if(layEvent === 'addcar'){

                layer.open({
                    cancel: function(index, layero){
                        var faIndex = index;
                        layer.confirm('确定要关闭么?未保存的信息将会丢失!', {icon: 3, title:'提示'}, function(index){
                            //do something
                            layer.close(index);
                            layer.close(faIndex);
                        });
                        return false
                    },
                    type: 2,
                    title: '加车',
                    maxmin: true,
                     //点击遮罩关闭层
                    area :  ['1200px' , '350px'],
                    content: ['./addCar.html','no'],
                    success:function(layero,index){
                        console.log(data);
                        var body = layer.getChildFrame('body',index);

                        for(var i in data){
                            body.contents().find("[name='"+i+"']").val(eval("data."+i));
                        }
                    },
                    end:function(){
                        var endurl ="";
                        endurl = url?url:contextPath+"/order";
                        $.ajax({
                            url:endurl,
                            // url: contextPath+"/order",

                            type: "GET",
                            contentType:"application/json;charset=utf-8",
                            dataType:"json",
                            success: function(res) {
                                table.render({
                                    elem: '#table'
                                    ,height:tableheight
                                    ,data:res.list
                                    ,page: {
                                        curr: currentPage //重新从第 1 页开始
                                    } //开启分页
                                    ,limit:10
                                    ,id:'table'
                                    ,cellMinWidth: tablewidth
                                    ,cols: [[ //表头
                                        {type:'numbers', title: '序号',  align:'center'}
                                        ,{field: 'ddh', title: '订单号' ,align:'center'}
                                        ,{field: 'ddzt', title: '订单状态',align:'center'}
                                        ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                        ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                        ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                        ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                        ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                        ,{field: 'huowu', title: '货物' ,align:'center'}
                                        ,{field: 'yunfei', title: '运费' ,align:'center'}
                                        ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                                    ]]

                                    ,done: function(res, curr, count){
                                        //得到当前页码
                                        console.log(curr);
                                        currentPage = curr;
                                    }
                                });
                            }

                        });
                    }
                });

            }
        });


//搜索
        var url ="";
        $("#search").on('click',function () {
            if($("#searchQsrqContent").val() != "" && $("#searchJsrqContent").val() != ""){
                if(!checkEndTime($("#searchQsrqContent").val(),$("#searchJsrqContent").val())){
                    layer.msg("起始日期大于结束日期!");
                }else {
                      url = contextPath+"/order?"+$("#khSearchKind").val()+"="+$("#khSearchContent").val()+"&"+$("#xlSearchKind").val()+"="+$("#xlSearchContent").val()+"&"+$("#qySearchKind").val()+"="+$("#qySearchContent").val()+"&"+"ddzt"+"="+$("#ddSearchContent").val()+ "&ddh="+ $("#ddhSearchContent").val()+"&qsrq="+$("#searchQsrqContent").val()+"&"+"jsrq="+$("#searchJsrqContent").val()+"&xq=" +$("#xingqi").val();
                    console.log(url);
                    $.ajax({
                        url: url ,
                        type: "GET",
                        contentType:"application/json;charset=utf-8",
                        dataType:"json",
                        success: function(res) {
                            table.render({
                                elem: '#table'
                                ,height:tableheight
//                    ,url:  contextPath+"/"//数据接口
                                ,data:res.list
                                ,page: true //开启分页
                                ,limit:10
                                ,cellMinWidth: tablewidth
                                ,cols: [[ //表头
                                    { type:'numbers', title: '序号',  align:'center'  }
                                    ,{field: 'ddh', title: '订单号' ,align:'center'}
                                    ,{field: 'ddzt', title: '订单状态',align:'center'}
                                    ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                    ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                    ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                    ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                    ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                    ,{field: 'huowu', title: '货物' ,align:'center'}
                                    ,{field: 'yunfei', title: '运费' ,align:'center'}
                                    ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                                ]]
                                ,done: function(res, curr, count){
                                    //得到当前页码
                                    console.log(curr);
                                    currentPage = curr;
                                }
                            });
                        }
                    });
                }
            }else if($("#searchQsrqContent").val() != "" && $("#searchJsrqContent").val() == ""){
                layer.msg("结束日期不能为空！");
            }else if($("#searchQsrqContent").val() == "" && $("#searchJsrqContent").val() != ""){
                layer.msg("起始日期不能为空！");
            }else {

                 url = contextPath+"/order?"+$("#khSearchKind").val().toString()+"="+$("#khSearchContent").val()+"&"+$("#xlSearchKind").val()+"="+$("#xlSearchContent").val()+"&"+$("#qySearchKind").val()+"="+$("#qySearchContent").val()+"&"+"ddzt"+"="+$("#ddSearchContent").val()+ "&ddh="+ $("#ddhSearchContent").val()+"&xq=" +$("#xingqi").val();
                console.log(url);
                $.ajax({
                    url: url ,
                    type: "GET",
                    contentType:"application/json;charset=utf-8",
                    dataType:"json",
                    success: function(res) {
                        table.render({
                            elem: '#table'
                            ,height:tableheight
//                    ,url:  contextPath+"/"//数据接口
                            ,data:res.list
                            ,page: true //开启分页
                            ,limit:10
                            ,cellMinWidth: tablewidth
                            ,cols: [[ //表头
                                { type:'numbers', title: '序号',  align:'center'  }
                                ,{field: 'ddh', title: '订单号' ,align:'center'}
                                ,{field: 'ddzt', title: '订单状态',align:'center'}
                                ,{field: 'ddrq', title: '订单日期' ,align:'center'}
                                ,{field: 'ddlx', title: '订单类型' ,  align:'center'}
                                ,{field: 'khjc', title: '客户简称' ,  align:'center'}
                                ,{field: 'qymc', title: '区域名称' ,  align:'center'}
                                ,{field: 'xlmc', title: '线路名称' ,  align:'center'}
                                ,{field: 'huowu', title: '货物' ,align:'center'}
                                ,{field: 'yunfei', title: '运费' ,align:'center'}
                                ,{ title:'操作', align:'center', toolbar: '#opera',width:200}
                            ]]
                            ,done: function(res, curr, count){
                                //得到当前页码
                                console.log(curr);
                                currentPage = curr;
                            }
                        });
                    }
                });
            }
        });


    });





</script>
</body>
</html>